<?php
	function finalizeOrder(&$params, &$errors)
	{
		global $connection;
		
		$clientID = 0;
		$orderID = 0;
		
		$client = getLoginData();
		if(!isset($client["id"]))
		{
			if($params["create_account"] == 0)
			{
				$params["params"]["type"] = 3;
				$clientID = $connection->insert("clients", $params["params"]);
			}
			else
			{
				$clientID = $connection->insert("clients", $params["params"]);
				if($clientID > 0)
				{
					login($clientID);
				}
				else
				{
					$errors["unknown_error"] = translate("unknown_error");
				}
			}
		}
		else
		{
			$clientID = $client["id"];
		}
		
		$products = getCartProducts();
		if(count($products) > 0)
		{
			
			$orderData["client_id"] = $clientID; 
			$orderData["completed"] = 0;
			$orderData["store_order"] = $params["payment_method"];
			$oderData["date"] = time();
			$orderData["delivery_name"] = $params["delivery_name"];
			$orderData["delivery_country_id"] = $params["delivery_country_id"];
			$orderData["delivery_county_id"] = $params["delivery_county_id"];
			$orderData["delivery_city_id"] = $params["delivery_city_id"];
			$orderData["delivery_address"] = $params["delivery_address"];
			$orderData["delivery_phone"] = $params["delivery_phone"];
			$orderData["delivery_zip_code"] = $params["delivery_zip_code"];
			$orderData["language_id"] = $_SESSION["language"]["id"];
			
			$orderReward = 0;
			$orderRewardUsed = 0;
			
			$rewardValue = get_setting("thankyou_value");
			
			if($rewardValue > 0)
			{
				if($products[0]["reward_discount"]["points"] > 0)
				{
					$orderRewardUsed = $products[0]["reward_discount"]["points"];
					
					$rewardParams[] = $client["id"];
					$query = "UPDATE clients SET reward_points = reward_points - ".$products[0]["reward_discount"]["points"]." 
								WHERE id = ?";
					$connection->execute_query($query, $rewardParams);
				}
				
				$orderReward = $rewardValue*$products[0]["grand_total"];
			}
			
			$orderData["reward_points"] = $orderReward;
			$orderData["reward_points_used"] = $orderRewardUsed;
				
			$orderID = $connection->insert("orders", $orderData);
			if($orderID > 0)
			{
				foreach($products as $product)
				{
					$productData["order_id"] = $orderID;
					$productData["stock_id"] = $product["stock_id"];
					$productData["product"] = $product["id"];
					
					$productData["quantity"] = $product["quantity"];
					$productData["price"] = $product["min_price"];
					$productData["old_price"] = $product["max_price"];
					if(isset($products[0]["discounts"]))
					{
						foreach($products[0]["discounts"] as $code => $discount)
						{
							if($product["id"] == $discount["product_id"])
							{
								$productData["coupon_code"] = $code;
							}
						}
					}
					$connection->insert("order_items", $productData);
				}
				
				$_SESSION["Payment_Amount"] = $products[0]["grand_total"];
				
				include("../helpers/Email.php");
				
				$emailContent = generateEmailContent($products, $params, $client);
				
				$email = new Email();
				$config['mailtype'] = 'html';
				
				$companyEmail = get_setting("contact_email");
				$companyName = get_setting("company_name");
				
				$email->initialize ( $config );
				$email->from($companyEmail, $companyName);
				$email->to($client['email']); 
				//$email->cc('we@yahoo.com'); 
				//$email->bcc('them@their-example.com'); 
				$email->subject(translate("order_email")." - ".$companyName);
				$email->message($emailContent);	
				$email->send();
			}
			else
			{
				$errors["unkown_error"] = translate("unknown_error");
			}
		}
		else
		{
			$errors["order_error_no_products"];
		}
		
		return $orderID;
		
	}
	
	function getPayPalForm($params)
	{
		//$paypal_url = "https://www.paypal.com/cgi-bin/webscr"; // LIVE Paypal API URL
		
		$paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
		$paypal_id = 'loralpar-facilitator@yahoo.com'; // Business email ID
		$products = getCartProducts();
		if(count($products) > 0):
		?>
		<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal1">
			<input type="hidden" name="charset" value="utf-8">
		    <input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
		    <input type="hidden" name="cmd" value="_xclick">
		    <input type="hidden" class="orderID" name="item_name" value="<?php translate("order");?>">  
		    <input type="hidden" class="orderID" name="item_number" value="1">
		    <input type="hidden" name="credits" value="510">
		    <input type="hidden" name="userid" value="1">
		    <input type="hidden" name="amount" value="<?php echo $products[0]["grand_total"]?>">
		    <input type="hidden" name="cpp_header_image" value="<?php echo site_url().get_setting("logo");?>">
		    <input type="hidden" name="no_shipping" value="1">
		    <input type="hidden" name="currency_code" value="<?php echo get_setting("currency"); ?>" />
		    <input type="hidden" name="handling" value="0">
		    <input type="hidden" name="cancel_return" value="<?php echo site_url(); ?>cancel-order.html">
		    <input type="hidden" name="return" value="<?php echo site_url(); ?>finalize-order.html">
		    <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
		    <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
	    </form> 
		<?php endif;
	}
	
	function getCheckoutForm($params)
	{
		$products = getCartProducts();
		if(count($products) > 0):
		?>
		<script src="https://www.2checkout.com/static/checkout/javascript/direct.min.js"></script>
		
		<form action='https://www.2checkout.com/checkout/purchase' method='post'>
			<input type='hidden' name='sid' value='<?php echo get_setting("2checkout_id"); ?>' />
			<input type='hidden' name='mode' value='2CO' />
			
			
			<?php $productIndex = 0; foreach($products as $product): ?>
				<?php
					$description = htmlentities(strip_tags($product["description"]));
					$description = substr($description, 0, 100)."...";
				?>
			<input type='hidden' name='li_<?php echo $productIndex; ?>_name' value='<?php echo $product["name"]; ?>' />
			<input type='hidden' name='li_<?php echo $productIndex; ?>_price' value='<?php echo $product["min_price"]; ?>' />
			<input type='hidden' name='li_<?php echo $productIndex; ?>_quantity' value='<?php echo $product["quantity"]; ?>' />
			<input type='hidden' name='li_<?php echo $productIndex; ?>_description' value='<?php echo $product["quantity"]; ?>' />
			<?php $productIndex++; endforeach; ?>
			
			<input type="hidden" name="merchant_order_id" class="orderID" value=""/>
			<input type="hidden" name="currency_code" value="<?php echo get_setting("currency"); ?>"/>
			
			
			<input type='hidden' name='x_receipt_link_url' value='<?php echo site_url(); ?>finalize-order.html' />
			
			<input type='hidden' name='card_holder_name' value='<?php echo $params["name"]; ?>' />
			<input type='hidden' name='street_address' value='<?php echo $params["address"]; ?>' />
			<input type='hidden' name='city' value='<?php echo $params["city_name"]; ?>' />
			<input type='hidden' name='state' value='<?php echo $params["county_name"]; ?>' />
			<input type='hidden' name='zip' value='<?php echo $params["zip_code"]; ?>' />
			<input type='hidden' name='country' value='<?php echo $params["country_name"]; ?>' />
			<input type='hidden' name='email' value='<?php echo $params["email"]; ?>' />
			<input type='hidden' name='phone' value='<?php echo $params["phone"]; ?>' />
			
			<input type='hidden' name='key' value='<?php echo $params["email"]; ?>' />
			<input type='hidden' name='total' value='<?php echo $products[0]["grand_total"]; ?>' />
			
			
			
			<button id="2checkout" type="submit" class="btn btn-default btn-danger btn-lg pull-right hidden">
				<?php echo translate("continue"); ?>
			</button>
		</form>
		
		<?php
		endif;
	}
	
	function generateEmailContent($products, $params,$client, $order = null)
	{
		global $connection;
		
		$site = verify_site();
		
		$country = $connection->fetch_row("countries", $client["country_id"]);
		$county = $connection->fetch_row("counties", $client["county_id"]);
		$city = $connection->fetch_row("cities", $client["city_id"]);
		$content = 
		'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
			<html>
			  <head>
			    <meta http-equiv="Content-Type" content="text/html;
			      charset=ISO-8859-1">
			    <meta content="MSHTML 6.00.2900.3698" name="GENERATOR">
			    <style></style>
			  </head>
			  <body text="#'.get_setting("body-font-color").'" bgcolor="#'.get_setting("background").'" style="font-family:Arial, sans-serif;">
			    <br>
			    <br>
			    <div style="width:672px;margin:0px auto;background-color:#'.get_setting("alt-header-color").';height: 52px;">
			    <a href="'.site_url().'" title="">
		    		<img src ="'.scripts_url().get_setting("logo").'" alt=""/>
		    	</a>
		    	</div>
			    <br />
			    <table width="670" align="center" border="0" cellpadding="0"
			      cellspacing="0">
			      <tbody>
			        <tr>
			          <td style="border: 1px solid rgb(237, 237, 235); background:
			            none repeat scroll 0% 0% #'.get_setting("footer-and-breadcrumbs").';" valign="top">
			            <table width="100%" border="0" cellpadding="0"
			              cellspacing="0">
			              <tbody>
			                <tr>
			                  <td style="padding: 3px; font-size: 16px; color:
			                    rgb(77, 77, 77); border-bottom: 1px dashed rgb(102,
			                    102, 102); font-family: Arial, sans-serif; text-align: left;"
			                    width="50%">'.translate("order_number").': '.(isset($order["id"]) ? $order["id"] : "1").'</td>
			                  <td style="padding: 3px; font-size: 12px; color:
			                    rgb(77, 77, 77); border-bottom: 1px dashed rgb(102,
			                    102, 102); font-family: Arial, sans-serif; text-align: right;"
			                    width="50%">'.translate("sent_at")." ".date("d.m.Y h:i:s", time()).'</td>
			                </tr>
			                <tr>
			                  <td style="padding-left: 5px; font-size: 14px;
			                    padding-bottom: 15px; color: rgb(109, 109, 109);
			                    padding-top: 15px; text-align: left;" valign="top">
								<strong>Date contact</strong> <br>
								<?php echo $client_name; ?><br>';
				
			
				if ( $client['client_type'] == 0 || $client["type"] == 3)
				{
					
					
					$content .= translate("address").": ".$client['address']. " <br> ".$city["name"].translate("county").
								": ".$county["name"]."<br>". $client['zip_code'] ."<br>".$country["name"]."<br />";
				}
				elseif($client['client_type'] == 1)
				{
					$content .= translate("headquarters").": ".$client['address']. " <br> ".$city["name"].translate("county").
								": ".$county["name"]."<br>". $client['zip_code'] ."<br>".$country["name"]."<br />";
                    $content .= translate("registration_number")." : ".$client['registration_number']."<br>";
                    $content .= translate("CUI")." : ". $client['unique_code'] . "<br>";
                    $content .= translate("bank_account"). " : " . $client['bank_account'] ."<br>";
                    $content .= translate("bank_name"). " : " .$client['bank_name'] . "<br>";
				 	$content .= translate("contect_person"). " : " .$client['company_contact_name'] . "<br>";
				}
								
                $content .= translate("phone") . "/".translate("fax")." : ". implode(', ', array($client['phone'], $client['fax'])) ."<br>";
                $content .= translate("email") . '<a moz-do-not-send="true" href="mailto:'.$client['email'].'">'.$client['email'].'</a><br>';
		    	
				
				
			if ( $order['store_order'] == 2 )
			{
				$content .= translate("payment_method_cash_on_delivery")."<br />";
				$deliveryCountry = $connection->fetch_row("countries", $client["delivery_country_id"]);
				$deliveryCounty = $connection->fetch_row("counties", $client["delivery_county_id"]);
				$deliveryCity = $connection->fetch_row("cities", $client["delivery_city_id"]);
				
				$content .= translate("address").": ".$order['delivery_address']."<br>";
				
				$content .= $deliveryCountry["name"] .", ". translate("county") . " " . $deliveryCounty["name"]. "<br>".$deliveryCountry["name"];
				$content .= "<br />" . $order['delivery_zip_code'] . "<br>";
				$content .= translate("phone")." ".implode(', ', array($order['delivery_phone']))."<br>";
				
				
			}
			
			$content .= '</td>
		                  <td style="padding-right: 5px; font-size: 14px;
		                    padding-bottom: 15px; color: rgb(109, 109, 109);
		                    padding-top: 15px; text-align: right;" valign="top">
							<strong>&nbsp;</strong><br>'.$site["name"]."<br>";
			$content .= translate("headquarters")."<br />".get_setting("contact_address")."<br>";
            $content .= translate("phone"). " ". get_setting("contact_telephone")."<br />";
            $content .= translate("email").": <a moz-do-not-send='true' href='mailto:".get_setting("contact_email")."'>".get_setting("contact_email")."</a>";
         	$content .="     </td>
			                </tr>
			              </tbody>
			            </table>
			          </td>
			        </tr>";
			$content .= '<tr>
				          <td>
				            <table width="98%" align="center" border="0" cellpadding="0"
				              cellspacing="0">
				              <tbody>
				                <tr>
				                  <td style="padding: 3px; border-top: 1px solid rgb(85,
				                    86, 76); font-weight: bold; font-size: 14px;
				                    border-left: 2px solid rgb(85, 86, 76); color:
				                    rgb(85, 86, 76); border-bottom: 1px solid rgb(85,
				                    86, 76); font-family: Arial, sans-serif;" width="5%"
				                    align="middle">#ID</td>
				                  <td style="padding: 3px; border-top: 1px solid rgb(85,
				                    86, 76); font-weight: bold; font-size: 14px;
				                    border-left: 1px solid rgb(85, 86, 76); color:
				                    rgb(85, 86, 76); border-bottom: 1px solid rgb(85,
				                    86, 76); font-family: Arial, sans-serif;" width="40%"
				                    align="middle">'.translate("product_name").'<br />'.
				                    translate("or")." ".translate("service_name").'</td>
				                  <td style="padding: 3px; border-top: 1px solid rgb(85,
				                    86, 76); font-weight: bold; font-size: 14px;
				                    border-left: 1px solid rgb(85, 86, 76); color:
				                    rgb(85, 86, 76); border-bottom: 1px solid rgb(85,
				                    86, 76); font-family: Arial, sans-serif;" width="10%"
				                    align="middle">'.translate("quantity_metrics").'<br>
				                    &nbsp; <br>
				                    &nbsp;</td>
				                  <td style="padding: 3px; border-top: 1px solid rgb(85,
				                    86, 76); font-weight: bold; font-size: 14px;
				                    border-left: 1px solid rgb(85, 86, 76); color:
				                    rgb(85, 86, 76); border-bottom: 1px solid rgb(85,
				                    86, 76);" width="10%"
				                    align="middle">'.translate("quantity").'<br>
				                    &nbsp; <br>
				                    &nbsp;</td>
				                  <td style="padding: 3px; border-top: 1px solid rgb(85,
				                    86, 76); font-weight: bold; font-size: 14px;
				                    border-left: 1px solid rgb(85, 86, 76); color:
				                    rgb(85, 86, 76); border-bottom: 1px solid rgb(85,
				                    86, 76); font-family: Arial, sans-serif;" width="15%"
				                    align="middle">'.translate("price").'<br>
				                    '.translate("with_VAT").'<br>
				                    '.get_setting("currency").'</td>
				                  <td style="padding: 3px; border-top: 1px solid rgb(85,
				                    86, 76); font-weight: bold; font-size: 14px;
				                    border-left: 1px solid rgb(85, 86, 76); color:
				                    rgb(85, 86, 76); border-bottom: 1px solid rgb(85,
				                    86, 76); font-family: Arial, sans-serif;" width="15%"
				                    align="middle">'.translate("value").'<br>
				                    &nbsp; <br>
				                    '.get_setting("currency").'</td>
				                  <td style="border-right: 2px solid rgb(85, 86, 76);
				                    padding: 3px; border-width: 1px 2px 1px 1px;
				                    border-style: solid; border-color: rgb(85, 86, 76);
				                    font-weight: bold; font-size: 14px; color: rgb(85,
				                    86, 76); font-family: Arial, sans-serif;" width="15%"
				                    align="middle"><br />'.translate("VAT")."<br/>".get_setting("VAT").'%<br>
				                    &nbsp; <br>
				                    &nbsp;</td>
				                </tr>';

			$productCount = count($products);
			$productIndex = 1;
			foreach($products as $product)
			{
				$content .= '
				 <tr>
                  <td style="padding: 3px; font-size: 14px; border-left:
                    2px solid rgb(85, 86, 76); color: black;
                    font-family: Arial, sans-serif;">'.$productIndex.'</td>
                  <td style="padding: 3px; font-size: 14px; border-left:
                    1px solid rgb(85, 86, 76); color: red; font-family:
                    Arial, sans-serif;"><a moz-do-not-send="true" style="color:
                      green;"
                      href="'.$product["url"].'">
						'.$product["name"].'
					  </a>';
					  
					  if(count($product["properties"]) > 0)
					{
							$content .= ' <br /><span style="color:grey;">';
							$count = 1;
							$propCount = count($product["properties"]);
							foreach ($product["properties"] as $property) 
							{
								$content .=  ucfirst($property["name"]). " : ";
								foreach($property["values"] as $value)
								{
									$content .= strtoupper($value["name"]);
								} 
								if($count < $propCount)
								{
									$content .= ";";
								}
								$count++;
							}
							$content .= "</span>";
					}
					
					$vat = ($product["total_price"]*get_setting("vat"))/100;
					$vat = makePriceInterval($vat, 0, get_setting("currency"));
					
					$content .= '  
								  </td>
			                  <td style="padding: 3px; font-size: 14px; border-left:
			                    1px solid rgb(85, 86, 76); color: black;
			                    font-family: Arial, sans-serif;text-align:center;" valign="middle">'.translate("piece").'</td>
			                  <td style="padding: 3px; font-size: 14px; border-left:
			                    1px solid rgb(85, 86, 76); color: black;
			                    font-family: Arial, sans-serif;text-align:center;" align="right" valign="middle">'.$product['quantity'].'</td>
			                  <td style="padding: 3px; font-size: 14px; border-left:
			                    1px solid rgb(85, 86, 76); color: black;
			                    font-family: Arial, sans-serif;" align="right">'.$product["price"].'</td>
			                  <td style="padding: 3px; font-size: 14px; border-left:
			                    1px solid rgb(85, 86, 76); color: black;
			                    font-family: Arial, sans-serif;" align="right" valign="middle">'.makePriceInterval($product["total_price"],0,get_setting("currency")).'</td>
			                  <td style="border-right: 2px solid rgb(85, 86, 76);
			                    padding: 3px; font-size: 14px; border-left: 1px
			                    solid rgb(85, 86, 76); color: black; font-family:
			                    Arial, sans-serif;" align="right" valign="middle">'. $vat .'</td>
                				</tr>';
                	$productIndex++;
			}
			
			$transportVat = ($products[0]["transport_price"]*get_setting("vat"))/100;
			$transportVat = makePriceInterval($transportVat, 0, get_setting("currency"));
			
			$content .= '
				<tr>
	                  <td style="padding: 3px; font-size: 14px; border-left:
	                    2px solid rgb(85, 86, 76); color: black;
	                    font-family: Arial, sans-serif;">'.$productIndex.'</td>
	                  <td style="padding: 3px; font-size: 14px; border-left:
	                    1px solid rgb(85, 86, 76); color: red; font-family:
	                    Arial, sans-serif;">'.translate("transport_price").'</td>
	                  <td style="padding: 3px; font-size: 14px; border-left:
	                    1px solid rgb(85, 86, 76); color: black;
	                    font-family: Arial, sans-serif;text-align:center;">-</td>
	                  <td style="padding: 3px; font-size: 14px; border-left:
	                    1px solid rgb(85, 86, 76); color: black;
	                    font-family: Arial, sans-serif;text-align:center;" align="ceneter">1</td>
	                  <td style="padding: 3px; font-size: 14px; border-left:
	                    1px solid rgb(85, 86, 76); color: black;
	                    font-family: Arial, sans-serif;" align="right">'.$products[0]["transport_price"].'</td>
	                  <td style="padding: 3px; font-size: 14px; border-left:
	                    1px solid rgb(85, 86, 76); color: black;
	                    font-family: Arial, sans-serif;" align="right">'.$products[0]["transport_price"].'</td>
	                  <td style="border-right: 2px solid rgb(85, 86, 76);
	                    padding: 3px; font-size: 14px; border-left: 1px
	                    solid rgb(85, 86, 76); color: black; font-family:
	                    Arial, sans-serif;" align="right">'.$transportVat.'</td>
	                </tr>'; 
	           $productIndex++;
	     if(isset($products[0]["discounts"]))
	     {
	     	foreach($products[0]["discounts"] as $key =>  $discount)
	     	{
	     		
				$discountVAT = ($discount["value"]*get_setting("vat"))/100;
				$discountVAT = makePriceInterval($discountVAT, 0, get_setting("currency"));
				
	     		$content.= '<tr>
	    			<td style="padding: 3px; font-size: 14px; border-left:2px solid rgb(85, 86, 76); color: black;font-family: Arial, sans-serif;">
	        			'.$productIndex.'
	        		</td>
	              <td style="padding: 3px; font-size: 14px; border-left:1px solid rgb(85, 86, 76); color: black; font-family:Arial, sans-serif;">
	              	'.translate("coupon").': '.$key.'
	              </td>
	              <td style="padding: 3px; font-size: 14px; border-left:
	                1px solid rgb(85, 86, 76); color: black;
	                font-family: Arial, sans-serif;text-align:center;">-</td>
	              <td style="padding: 3px; font-size: 14px; border-left:
	                1px solid rgb(85, 86, 76); color: black;
	                font-family: Arial, sans-serif;text-align:center;" align="center">1</td>
	              <td style="padding: 3px; font-size: 14px; border-left:
	                1px solid rgb(85, 86, 76); color: black;
	                font-family: Arial, sans-serif;" align="right">
	                	-'.makePriceInterval($discount["value"], 0, get_setting("currency")).'
	        		</td>
	              <td style="padding: 3px; font-size: 14px; border-left:
	                1px solid rgb(85, 86, 76); color: black;
	                font-family: Arial, sans-serif;" align="right">
	                -'.makePriceInterval($discount["value"], 0, get_setting("currency")).'
					</td>
	              <td style="border-right: 2px solid rgb(85, 86, 76);
	                padding: 3px; font-size: 14px; border-left: 1px
	                solid rgb(85, 86, 76); color: black; font-family:
	                Arial, sans-serif;" align="right">
	                '.$discountVAT.'
	               </td>
	    		 </tr>';
	    		 
	    		 $productIndex++;
	     	}
	     	
	     }
		
		$totalVAT = ($products[0]["grand_total"]*get_setting("vat"))/100;
		$totalVAT = makePriceInterval($totalVAT, 0, get_setting("currency"));
		
		$termsPage = get_site_page_by_slug("terms-and-conditions", $_SESSION["language"]["id"]);
		
		$content .= '
				<tr>
                  <td style="border-top: 1px solid rgb(85, 86, 76);">&nbsp;</td>
                  <td style="border-top: 1px solid rgb(85, 86, 76);">&nbsp;</td>
                  <td style="border-top: 1px solid rgb(85, 86, 76);">&nbsp;</td>
                  <td style="border-top: 1px solid rgb(85, 86, 76);">&nbsp;</td>
                  <td style="border-top: 1px solid rgb(85, 86, 76);">&nbsp;</td>
                  <td style="border-top: 2px solid rgb(85, 86, 76);
                    font-weight: bold; font-size: 14px; border-left: 2px
                    solid rgb(85, 86, 76); color: rgb(95, 95, 95);
                    border-bottom: 2px solid rgb(85, 86, 76);
                    font-family: Arial, sans-serif;" align="right">'.makePriceInterval($products[0]["grand_total"], 0, get_setting("currency")).'</td>
                  <td style="border: 2px solid rgb(85, 86, 76);
                    font-weight: bold; font-size: 14px; color: rgb(95,
                    95, 95); font-family: Arial, sans-serif;" align="right">'.$totalVAT.'</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td style="font-weight: bold; font-size: 16px; color:#f4a908;
                   font-family: Arial, sans-serif;">'.translate("grand_total").':'.makePriceInterval($products[0]["grand_total"], 0, get_setting("currency")).'</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
        <tr>
          <td style="border: 1px solid rgb(237, 237, 235); background:
            none repeat scroll 0% 0% rgb(243, 243, 241);">
            <table width="100%" border="0" cellpadding="0"
              cellspacing="0">
              <tbody>
                <tr>
                  <td style="padding: 5px; font-size: 12px; color:
                    rgb(95, 95, 95); border-bottom: 1px solid rgb(148,
                    149, 142); font-family: Arial;">
                    <div style="font-weight: bold; font-size: 14px;
                      padding-bottom: 5px;">
                      <a href="'.site_url().$termsPage["url"].".html".'" title="">'.$termsPage["name"].'</a></div>';
        $content .= translate("payment_method").":"."<br>";
		

		if ( $params['store_order'] == 0 )
		{
			$content .= translate("payment_method_store_pickup");
		}
		elseif($params['store_order'] == 1)
		{
			$content .= translate("payment_method_cash_on_delivery");
		}
		elseif($params["store_order"] == 2)
		{
			$content .= translate("payment_method_paypal");
		}
		elseif($params["store_order"] == 3)
		{
			$content .= translate("payment_method_card");
		}
        
        $content .= '
        			</tr>
		                <tr>
		                  <td style="padding: 5px; font-size: 12px; color:
		                    rgb(95, 95, 95); border-bottom: 1px solid rgb(148,
		                    149, 142); font-family: Arial;"><strong>Expeditie:</strong><br>
							</td>
		                </tr>
		                <tr>
		                  <td style="padding: 5px; font-size: 12px; color:
		                    rgb(95, 95, 95); font-family: Arial;"><strong>Nota:</strong><br>
		                    Preturile pot fi modificate fara notificare si sunt
		                    valabile in limita stocului disponibil.<br>
		                    Comanda transmisa on-line constituie obligatie
		                    contractuala numai dupa confirmarea acesteia.</td>
				                </tr>
				              </tbody>
				            </table>
				          </td>
				        </tr>
				      </tbody>
				    </table>
				  </body>
				</html>';
				
		return $content;
		
	}
?>